package com.yc.forum.filter;
import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.net.URLEncoder;
@WebFilter({"/SavePostServlet.s","/PutOneReplyServlet.s","/PutProblemServlet.s"})
public class SensitiveWordsFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json;charset=utf-8");
        HttpServletRequest req=(HttpServletRequest) request;
        MyFilter myf =new MyFilter(req);
        System.out.println("-----------init myFilter-------------");
        chain.doFilter(myf, response);
    }

    @Override
    public void destroy() {

    }
}
